<%--
  Created by IntelliJ IDEA.
  User: 化风为雨
  Date: 2019/2/5
  Time: 16:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    String static_path = path + "/static/alpha";
    String x_admin_path = path + "/static/X-admin-2.3";
%>
<html>

<head>
    <!-- X-admin -->
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <script type="text/javascript" src="<%=x_admin_path%>/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="<%=x_admin_path%>/css/font.css">
    <link rel="stylesheet" href="<%=x_admin_path%>/css/xadmin.css">
    <script type="text/javascript" src="<%=x_admin_path%>/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=x_admin_path%>/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="<%=path%>/index">首页</a>
        <a>组织管理</a>
        <a href="<%=path%>/manage/department/post_management/list">岗位管理</a>
        <a>
          <cite>岗位类别管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="insertPostType()"><i class="layui-icon"></i>新增类别</button>
    </xblock>
    <table class="layui-table layui-form">
        <thead>
        <tr>
            <th width="50">次序</th>
            <th>类别名称</th>
            <th width="220">操作</th>
        </thead>
        <tbody class="x-cate">
        <!-- 显示所有的岗位类别 -->
        <c:forEach items="${requestScope.postTypeList}" var="list" varStatus="i">
            <tr cate-id='${list.id}' fid='0' >
                <td>${i.count}</td>
                <td>
                    <c:if test="${!empty list.postTypeList}">
                        <i class="layui-icon x-show" status='true'>&#xe623;</i>${list.name}
                    </c:if>
                    <c:if test="${empty list.postTypeList}">
                        ${list.name}
                    </c:if>

                </td>
                <td class="td-manage">
                    <button class="layui-btn layui-btn layui-btn-xs"  onclick="updatePostType(${list.id},'${list.name}')" ><i class="layui-icon">&#xe642;</i>编辑</button>
                    <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'${list.id}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                </td>
            </tr>

            <c:forEach items="${list.postTypeList}" var="postList" varStatus="ii">
                <tr cate-id='${postList.id}' fid='${postList.prentId}' >
                    <td>${ii.count}</td>
                    <td>
                        &nbsp;&nbsp;&nbsp;&nbsp;${postList.name}
                    </td>
                    <td class="td-manage">
                        <button class="layui-btn layui-btn layui-btn-xs"  onclick="updatePostType2(${postList.id},'${postList.name}',${postList.prentId})" ><i class="layui-icon">&#xe642;</i>编辑</button>
                        <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(this,'${postList.id}')" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                    </td>
                </tr>
            </c:forEach>
        </c:forEach>


        </tbody>
    </table>
</div>
<style type="text/css">

</style>
<script>
    layui.use('form', function(){
        var layer = layui.layer
            ,form = layui.form;

    });

    /**新增类别*/
    function insertPostType() {
        //iframe层
        parent.layer.open({
            type: 2,
            title: '新增类别',
            shadeClose: false, //点击遮罩关闭
            shade: 0.8,
            area: ['40%', '50%'],
            maxmin: true,
            closeBtn: 1,
            content: ['<%=path%>/manage/department/post_management/insert?type=2', 'yes'], //iframe的url，yes是否有滚动条
            //yes: function (index, layero) {
            //    alert(index);
            //    alert(layero);
            //},
            end: function () {
                location.reload();
            }

        });
    }

    /**编辑一级类别*/
    function updatePostType(id,name) {
        //iframe层
        parent.layer.open({
            type: 2,
            title: '编辑类别',
            shadeClose: false, //点击遮罩关闭
            shade: 0.8,
            area: ['40%', '30%'],
            maxmin: true,
            closeBtn: 1,
            content: ['<%=path%>/manage/department/post_management/update?type=2&name='+name+'&id='+id, 'yes'], //iframe的url，yes是否有滚动条
            //yes: function (index, layero) {
            //    alert(index);
            //    alert(layero);
            //},
            end: function () {
                location.reload();
            }

        });
    }

    /**编辑二级类别*/
    function updatePostType2(id,name,prentId) {
        //iframe层
        parent.layer.open({
            type: 2,
            title: '编辑类别',
            shadeClose: false, //点击遮罩关闭
            shade: 0.8,
            area: ['40%', '50%'],
            maxmin: true,
            closeBtn: 1,
            content: ['<%=path%>/manage/department/post_management/update?type=3&name='+name+'&id='+id+'&prentId='+prentId, 'yes'], //iframe的url，yes是否有滚动条
            //yes: function (index, layero) {
            //    alert(index);
            //    alert(layero);
            //},
            end: function () {
                location.reload();
            }

        });
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){

            $.ajax({
                url:"<%=path%>/manage/department/post_management/Delete",
                type:"post",
                data:{postTypeId:id},
            });

            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }




</script>

</body>

</html>